import { v4 as uuidv4, validate as uuidValidate } from 'uuid'

export const AppAccessToken = 'token'
// export const AppImgBaseUrl = 'http://x0y0.bj01.bdysite.com/img/'

export const AppClientId = 'CurrentClientId'
export const SiteHost = 'https://di.show-me-code.xyz'
export const AppImgBaseUrl = SiteHost + '/img/'

/**
 * 获取当前应用UUID
 * @returns {string}
 */
export function currentAppClientId () {
  let clientId = localStorage.getItem(AppClientId)
  if (clientId == null) {
    clientId = uuidv4()
    localStorage.setItem(AppClientId, clientId)
  }
  const flag = uuidValidate(clientId)
  if (flag === false) {
    clientId = uuidv4()
    localStorage.setItem(AppClientId, clientId)
  }
  return clientId
}
